home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 1
/
Cream of the Crop 1.iso
/
UTILITY
/
DDIFF32.ARJ
/
DDIFF.DOC
next >
Wrap
Text File
|
1992-07-28
|
20KB
|
502 lines
DDIFF
A file difference reporting utility
version 3.2
7-28-92
by Doug McKay
Copyright (c) 1990, 1992 All Rights Reserved
What it is . . .
DDIFF is a program that will check to see if any files in a specified
directory tree have changed since the last time the utility was run.
Why use it . . .
If you want to find out what files have changed recently in a certain
directory (or directory tree), DDIFF will come in handy. It is especially
helpful on a network where many people may have access to certain files that
you need to keep track of. There are some useful examples of DDIFF toward the
end of this document.
How it does it . . .
DDIFF creates either one or two files for its own use depending upon how
you wish to use it.
The first is a Benchmark file containing the date and time of the last
time the utility was run. It also contains a list of all of the files in the
directory along with their dates, times, and sizes as they were at the time the
Benchmark file was created.
Here is a portion of a Benchmark file:
;DDIFF Benchmark created 7-2-1990 at 15:10
;
>C:\*.*
IO .SYS+ 33337 12-19-1988 0:00:02 A34D
MSDOS .SYS+ 37376 04-19-1989 8:38:32 CE44
DOUG'S + 0 04-25-1990 14:33:30 ----
BIZLINK + <DIR> 06-06-1990 9:22:18 ----
DOS + <DIR> 04-25-1990 14:02:46 ----
WP51 + <DIR> 04-25-1990 14:25:52 ----
AUTOEXEC.BAT~ 1668 07-02-1990 11:10:36 F44
COMMAND .COM+ 37557 12-19-1988 0:00:02 7633
CONFIG .SYS~ 370 07-02-1990 13:58:12 D912
;
>C:\BIZLINK\*.*
DOUG <DIR> 06-06-1990 9:24:34 ----
ATTACH .WPM~ 3739 05-24-1990 0:00:00 591A
ATTCHCTL.CMD~ 18258 06-18-1990 0:00:00 2544
BIZLINK .CMD~ 43434 06-18-1990 0:00:00 B7C6
BIZLINK .EXE` 48556 06-06-1990 0:00:00 2323
;
Notice that DDIFF picks up Hidden, System, and Read Only files (IO.SYS and
MSDOS.SYS). The file "DOUG'S" is not a file, but the Volume label on drive C:.
You'll also notice that DDIFF considers the seconds on a file's time stamp to
be significant (DOS doesn't display them, but they are there). Even if someone
resets the clock to the date and time that DOS displays for a particular file
and then modifies that file, DDIFF will likely report a difference due to the
seconds.
The next file (if you tell DDIFF to create it) is a Difference file
containing a list of all of the files that have been changed (according to
date, time, and filesize) since the Benchmark file was created.
Here is a portion of a Difference File:
;
;DDIFF Difference file created 8-2-1990 at 11:39
;Benchmark file used: 'DDIFF.LOG'.
;
>C:\LIBRARY\*.*
DM_}ED .SET~ 332 08-02-1990 11:18:22 C69A Time
; 1 - Difference(s)
;
>C:\TC\WORK\DDIFF\*.*
DDIFF .EXE~ 14363 08-02-1990 11:29:16 9F3C CRC Size Time
DDIFF .LOG~ 155746 08-02-1990 11:30:32 77B2 CRC Size Time
DDIFF .OBJ~ 19380 08-02-1990 11:19:02 8F33 Date Time
DDIFF .DIF~ 766 08-02-1990 11:23:36 AC4E Added
DDIFF .PRJ+ 6435 08-02-1990 11:18:12 8BE7 CRC Size Time
DDIFF .CPP~ 36598 08-02-1990 11:18:46 7E15 CRC Size Time
DDIFF .BAK~ 36615 08-02-1990 11:14:38 ---- Deleted
; 7 - Difference(s)
;
; 91 - total Directories processed
; 1255 - total Items processed
; 8 - total Difference(s)
Note that DDIFF will find HIDDEN directories that are newly added or
deleted but will not check any files inside hidden directories for differences.
See the note about 'A Little Trick' below.
When DDIFF checks your files, it reads the Benchmark file and compares it
against the current contents of the directories that you told it to check. If
it finds files that have been changed, it writes a list of them to a Difference
file (and/or optionally, to the screen).
Archive bit display
Note the '~' and '+' symbols to the right of the file extensions. These
characters tell you whether or not the file has been changed since the last
time you backed up your hard disk (something that can never be done too often).
A '~' means that the file is not backed up. It means that the file has been
changed since the last backup and should be backed up again (ideally you won't
have very many of these). A '+' means that the file has been backed up and has
not been changed since that time. These symbols are controlled by the archive
bit of the file. DOS resets this flag each time the file is saved to disk, or
is otherwise changed. Most backup programs (indeed any that are worthwhile)
will reset the archive bit (turn it off) on a file after the file has been suc-
cessfully backed up. For this reason, this flag is not used by DDIFF in deter-
mining if a file is 'different', it is merely displayed as an informational
item so that the user can tell when it's time to do another backup.
Running it . . .
DDIFF has many options that tell it exactly what you want it to do. Each
time you run it, DDIFF will essentially do one of two things, create a
Benchmark file, or check a directory against an existing Benchmark file.
Usage: DDIFF option [option...] [path\[filespec]...]
■ When running DDIFF, you can have DDIFF.EXE anywhere that DOS can find
it (in the current directory or in your path).
■ You may specify any of DDIFF's options in any order whatsoever.
■ If you specify two conflicting options (like /M and /I) the last one
encountered will take precedence.
■ You must separate each option with a space. If you do not, DDIFF
will not be able to distinguish between them. For example, DDIFF
will interpret 'DDIFF /M/O' incorrectly (DDIFF will think you meant
'DDIFF /M-O'.
■ The dash '-' characters in certain parameters are necessary, without
them, DDIFF will get confused about what you want it to do.
■ If you do not specify any options, DDIFF displays its help screen.
Since there are so many different command line options, the following
section will explain each one in further detail.
The Finer Points
This is part of DDIFF's help screen. It displays a quick summary of each
option.
Usage: DDIFF option [option...] [path\[filespec...]]
Options
/M-file Make Benchmark file using 'file'
/C-file Check directory using 'file' as a Benchmark.
/D-file Write Difference file to 'file.'
/I-file Create an infobase from the Difference file. (Need CREATE.EXE)
/R Recursive operation (Operate on all subdirectories)
/CRC CRC Checking on. Much slower.
/U Unchanged files written to Difference file.
/O Overwrite old files.
/A Append to files.
/H Display this help screen.
path\ The 'path' to begin working in (MUST END WITH A '\' BACKSLASH)!
filespec The filename mask (default is '*.*') to use in 'path.'
/M-filename
Make a Benchmark file using 'filename'. If 'filename' is not specified,
the name DDIFF.LOG is used. This tells DDIFF to create a Benchmark file named
DDIFF.LOG in the current directory. Optionally you can specify a full path and
filename to tell DDIFF to create the Benchmark somewhere else.
/C-filename
Check a directory (or directory tree) against 'filename'. If 'filename'
is not specified, the name DDIFF.LOG is used. This tells DDIFF to compare a
directory (or directory tree) against the files and directories listed in the
Benchmark file. DDIFF compares each file that it finds against the information
included in the Benchmark file, and if anything is different (size, date, time,
or, if /CRC is included, the file's CRC), it reports what has changed by
writing it to a Difference file.
/D-filename
Create a Difference file named 'filename'. If 'filename' is not speci-
fied, the name DDIFF.DIF is used. This option is only needed if you wish to
use an alternate Difference file name.
This option is only valid when used with the /C option.
/I-filename
Create an infobase named 'filename' which contains the Differences. In
order for this option to operate correctly, the program CREATE.EXE (from the
VIEWS package) must be available somewhere in the DOS path. Using this option
automatically sets the following options: /C, /U and /O.
/R
No recursive operation. Use this option to restrict the program to
operation in only one directroy and to ignore all subdirectories.
/CRC
CRC Checking on. This option will turn on DDIFF's CRC checking feature.
In order to check the CRC of the files, they need to be read from the disk.
Since this takes time, using this option makes DDIFF much slower.
Because of the speed limitation, you may want to tell DDIFF to process
only certain files by including a file mask in the path parameter.
For example:
DDIFF /M-EXE.LOG /O /CRC C:\*.EXE
This command would create a Benchmark file named EXE.LOG in the current
directory (/M-EXE.LOG). If EXE.LOG already existed, it would be overwritten
(/O). CRC checking will be enabled (/CRC). All subdirectories would be
processed (no /R). All .EXE files on logical drive C: would be included in the
Benchmark (C:\*.EXE).
The CRC values given are calculated using an algorithm similar to that
used in various archive programs and file transmission protocols. The CRC
value is a 16 bit number. In the .LOG file, the CRC is displayed as four
hexadecimal digits just after the time.
If you see a file that has changed only in its CRC value, watch out, there
may be something funny going on (a virus may be involved). A file does not
normally change its CRC value without also changing its size, date and/or time.
If it does, be sure that you understand why (there are instances where this
would not be a problem -- self-modifying programs for example). If you don't
understand why the CRC value of a file may have changed, I would recommend
finding out why before working with that particular file again.
If a file cannot be opened for reading the CRC (e.g. directories, locked
files, and volume labels), four dashes ('----') will be inserted into the file
instead.
If the /CRC option is not included when checking a Benchmark file that was
created with the /CRC option, CRC checking will not be done and all file CRCs
will be displayed as '----'.
If the /CRC option is included when checking a Benchmark file that was not
created with the /CRC option, CRC checking will not be done and all file CRCs
will be displayed as '----'.
/U
Include unchanged files. If this option is specified, DDIFF will include
unchanged files in the Difference file (or display). Normally DDIFF only
reports the files which have changed since the last Benchmark was created.
This option will allow DDIFF to display ALL files.
When using the /I or /F options, /U is automatically set and cannot be
changed.
/F
This option tells DDIFF to format the Difference file for use with Folio
VIEWS. A number of markup codes will be inserted into the file which VIEWS
uses to generate a useable infobase.
/O
Overwrite Benchmark file. If this option is specified, DDIFF will automa-
tically overwrite an existing Benchmark file when creating a new Benchmark.
This option is only valid when used with the /M option.
/A
Append to Benchmark or Difference file. If this option is specified,
DDIFF will append all information that it produces to an existing Benchmark or
Difference file. If the file does not exist, it will be created. For example,
this option could be used when you want your Difference file to be a revision
history of each time that the files have (or have not) changed.
/H
Help. If this option is specified (anywhere) on the command line, DDIFF
will display its help screen and then exit.
path
The path to begin working on. If included, the path MUST end with the
backslash character ('\'). If it does not end in a backslash character (e.g.
'C:\UTIL'), DDIFF will use the intended directory name as a part of the 'file-
spec' parameter (see below). In the example, instead of using 'C:\UTIL\*.*'
(as intended) DDIFF would use 'C:\UTIL.*' and would only check the files named
'UTIL.*' in the root directory of drive C:.
filespec
The filename mask to use when searching for files. This can include the
wildcard characters '*' and '?.' If a filename or an extension is not supplied
(e.g. "TEST" or ".DOC" or nothing at all), the wildcard '*' will be supplied
automatically and the examples would become "TEST.*", "*.DOC", and "*.*"
respectively.
Errorlevels returned to DOS
When used with the /C option, DDIFF will return an errorlevel to DOS (for
use in batch files) indicating how many differences it found when comparing
files. If the number of differences exceeds 200, it will return an errorlevel
of 254. This was to allow for the following error messages to be reported via
errorlevel.
DDIFF will return the following error codes under the listed
circumstances.
249 ─ Out of Memory.
250 ─ Couldn't open Header file. (Only used with the /I option)
251 ─ Couldn't open Benchmark file.
252 ─ Couldn't open Difference file.
253 ─ DDIFF couldn't find anything useful to do. Most likely, /C or /M was
not specified.
The following segment of text is a batch file that controls what happens
when there are errors or certain numbers of differences.
diff /c /r c:\
if errorlevel 254 goto lots
if errorlevel 249 goto error
if errorlevel 11 goto some
if errorlevel 1 goto few
:none
echo There were No Differences.
goto end
:lots
echo There were Lots of differences (more than 200).
goto end
:some
echo There were Some differences (between 11 and 200).
goto end
:few
echo There were a Few differences (between 1 and 10).
goto end
:error
echo There was an error running DDIFF (don't know what kind).
:end
echo Done!
Note the order in which errorlevels are checked. When DOS sets an error-
level, all lower errorlevels become true. In other words, if DOS sets the
errorlevel to 100, then 99, 98, and everything down to 0 is set as well. For
this reason, you must check the highest errorlevels first, and work your way
down to the lower error levels.
When used with the /M option, DDIFF will return the following errorlevels.
0 ─ Successful in creating the Benchmark file.
1 ─ Terminated because the Benchmark file existed and /O or /A was not
specified.
249 ─ Out of memory.
251 ─ Couldn't open Benchmark file.
254 ─ DDIFF couldn't find anything useful to do. Most likely, /C, /M or /I
was not specified.
A Little Trick
If you use DDIFF to check your entire Hard Drive, you will find that it
will always report that the Benchmark file, and sometimes the Difference file
have been changed since the last run. In order to get around this, you can
create a hidden directory where DDIFF does not check files for differences. If
you store your Benchmark and your Difference files in a hidden directory, they
will not be checked for differences when scanning your entire drive. You will
be able to see if someone has created or deleted a hidden directory, but not if
they have made changes to the files within that directory.
To create a hidden directory requires a specialized utility. Normal DOS
will not allow you to create a hidden directory.
Specifications
DDIFF:
■ was written, compiled, and linked with Borland C++ 3.0 by Borland.
■ has been tested with MS-DOS 3.1, 4.01, and 5.0 and with Digital
Research's DR DOS 6.0.
■ will support up to 2200 files per directory (maximum due to memory
limitations).
■ will support unlimited directories on a single volume (hard disk).
■ was designed with command line or batch file operation in mind.
■ will be updated if bugs are found or enhancement requests are
received and implemented.
Examples
Here are a few ways that I have found DDIFF can be used. If you think
your way of using DDIFF could be widely used, let me know so I can document it
here.
Document Management System
This is a very simple use of DDIFF. It allows many people to make changes
to a group of documents in a given directory and allows you to check the
directory periodically to see if any of the documents have been updated in case
they need to be printed, or otherwise processed. This was the original reason
DDIFF was written.
To make the Benchmark, type the command:
DDIFF /M-C:\DDIFF.LOG /O C:\DOC\
To check the Benchmark tomorrow (or whenever), type the command:
DDIFF /C-C:\DDIFF.LOG /O C:\DOC\ /D-C:\DDIFF.DIF
The results of these two steps will be a file named DDIFF.DIF in C:\ which
contains a list of file that have changed.
Crude Security System
This is one way to make a Benchmark of, and later check, your entire hard
drive. This is a sort of crude security system that doesn't stop anyone from
making changes to your system, but does tell you what has been changed.
First, to make the Benchmark, you may be logged to any drive or any
directory you choose. then type the command:
DDIFF /M-C:\C&D.LOG /O /CRC C:\ D:\
DDIFF will create a Benchmark file named C&D.LOG in the root directory of
drive C:. If a file with that name already existed, DDIFF will overwrite it.
DDIFF will start in the root directory of drive C: and will process all of the
directories on the entire drive logging all files to C&D.LOG as it goes. It
will then do the same for drive D:.
Then whenever you want to check the entire hard drive against the
Benchmark, type the command:
DDIFF /C-C:\C&D.LOG C:\ D:\ /D-C:\C&D.DIF /CRC
DDIFF will look for an file in the root directory of drive C: named
C&D.LOG. It will then use this file to compare all directories on drive C:
(starting at the root directory) and log any differences to C&D.DIF in the root
directory of drive C:. It will do the same for drive D:. The result will be a
file named C:\C&D.DIF which will contain a list of files that had changed
between the time you made the Benchmark and the time you checked it.
Legal stuff
DDIFF 2.1 is a Freeware product. It is the property of Doug McKay. The
program is not sold. DDIFF 2.1 may be copied freely and distributed by anyone
as long as the original program and documentation files are distributed
together and unchanged. A reasonable fee may be charged for copying the
program or for a disk with the program on it, but not for the program itself.
I do not intend to make money from the registrations of DDIFF (hence the
price).
I claim no responsibility for any losses or damages caused by the use or
inability to use this program. It is distributed without any warranty written
or implied. I reserve the right to change any terms or options set forth in
this document at any time if I see necessary.
Doug McKay
549 Kennedy Road
Windsor, CT 06095-2243
(203) 298-9278 (voice)
(801) 375-9907 (BBS)
CIS: 72010,520